

<?php
	include("Connect/connection.php")
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/template.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<title>Eproject | Autocar</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/coin-slider.css" />
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/cufon-georgia.js"></script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="js/coin-slider.min.js"></script>
<script>
	function SearchForm(f) {
				if(document.getElementsByName('txtSearch')[0].value=='') {
					document.getElementsByName('txtSearch')[0].focus();
            		return false;
				}
				return true;
		}
</script>
</head>

<body>
<?php
	if($_REQUEST['btnSearch']){
		$name=$_REQUEST['txtSearch'];
		$searchby=$_REQUEST['company'];
		if($_REQUEST['btnSearch']){
			echo("<script>window.location='searchresult.php?name=$name&&by=$searchby'</script>");										        }	
	}
?>
<div class="main">
  <div class="header">
    <div class="header_resize">
      <div class="menu_nav">
        <ul>
          <li><a href="Home.php"><span>Home Page</span></a></li>
          <li><a href="news.php"><span>News</span></a></li>
          <li><a href="cars.php"><span>Cars</span></a></li>
          <li><a href="companies.php"><span>Provider</span></a></li>
          <li><a href="contactus.php"><span>Contact Us</span></a></li>
        </ul>
        <div class="search">
        	<form name="searchForm" enctype="multipart/form-data" method="post" action="" >
                <input type="text" name="txtSearch" class="txtSearch" />
                <select name="company" class="cbbSearch">
                    <option value="0">By Name</option>
                    <option value="1">By Manufacturers</option>                        
                </select>
                <input type="submit" value="Search" name="btnSearch" class="btnSearch" />
            </form>
      	</div>
      </div>
      
      <div class="logo">
        <h1><a href="index.html">A<span>uto</span>Shop</a></h1>
        
      </div>
      
      <div class="clr"></div>
    </div>
  </div>
  <div class="content">
    <div class="content_resize"><!-- InstanceBeginEditable name="content" -->
    <style>
	.comment-news{
		border:3px solid #CCC;
		margin: 50px 0;
	}
	.text-comment{
	background:#CCC;
	font-size:2em;
	padding:5px	
	}
	.form-comment{
		padding:20px;	
	}
	.textbox-comment{
		padding:5px;
		font-weight:bold;
		width:300px;
		border:1px solid #ccc	
	}
	.button-form{
		.background:#ccc;
		padding:5px 20px;
	}
	.show-comment{
		border-top:5px solid #ccc;
		margin:0 0 20px 0;
	}
	.title-comment{
		background:#ccc;
		font-size:2em;
		padding:10px 0 5px 0;
		text-align:center;
		width:120px;
		margin-top:20px;
	}
	.item-comment{
		display:block;
		padding:10px;
		border-bottom:1px dotted #ccc;
	}
	.person-name{
		font-size:1.5em;
		color:#06F;
		font-weight:bold
	}
	.person-email{
		color:#ccc;
		font-size:0.8em;
		font-weight:normal;
		margin-left:10px
	}
	.person-content{
		color:#000;
		padding-top:3px
	}
	</style>
    <script type="text/javascript">
		function ValidateComment(f) {
				if(document.getElementsByName('comment-name')[0].value=='') {
					alert('Please input Name');
					document.getElementsByName('comment-name')[0].focus();
            		return false;
				}
				if(document.getElementsByName('comment-email')[0].value=='') {
					alert('Please input Email');
					document.getElementsByName('comment-email')[0].focus();
            		return false;
				}
				if(document.getElementsByName('comment-title')[0].value=='') {
					alert('Please input Title');
					document.getElementsByName('comment-title')[0].focus();
            		return false;
				}
				if(document.getElementsByName('comment-content')[0].value=='') {
					alert('Please input Content');
					document.getElementsByName('comment-content')[0].focus();
            		return false;
				}
				return true;
		}
</script>
<?php
if($_REQUEST['btnSave']){
$name = $_POST['comment-name'];
$email = $_POST['comment-email'];
$title = $_POST['comment-title'];
$content = $_POST['comment-content'];
$newsId=$_REQUEST["id"];
$date = date('Y-m-d');

mysql_query("INSERT INTO commentcar (Name,Email,Title,Content,Status,CarID,TimeCommit) VALUES('$name','$email','$title','$content','1','$newsId','$date')") or die(mysql_error());

echo "<script>location.href='carsdetail.php?id=".$newsId."';</script>";
return;}
?>
      <div class="mainbar">
      <?php
					if(isset($_REQUEST["id"])){
						$id = $_REQUEST["id"];
						$query = mysql_query("select * from cars where CarID=$id");
						while($rs=mysql_fetch_array($query)){
							$title=$rs['Name'];
							$sub=$rs['Sumary'];
							$content=$rs['Content'];
							$status==$rs['Status'];
							$image=$rs['Image'];
							$company=$rs['ComID'];
							$date=$rs['TimeProduction'];
							$price=$rs['Price'];
							?>
 			<div style="width:100%;height:50px;font:Arial, Helvetica, sans-serif;font-size:24px;font-weight:bold;"><p style="margin-left:20px;color:#603;line-height:50px;">Car infomation </p></div>
            <div style="width:100%;height:230px">
            <div><img style="width:300px;float:left" src="images/<?=$image ?> " /></div>
            <div style="margin-left:320px;border-bottom:1px solid #CCC" ><p style="font:'Arial Black', Gadget, sans-serif;font-size:18px;font-weight:bold"><?= $title ?></p></div>
            <div style="margin-left:320px;border-bottom:1px solid #CCC" ><p style="font:'Arial Black', Gadget, sans-serif;font-size:16px">Price : <?= $price ?></p></div>
            <div style="margin-left:320px;border-bottom:1px solid #CCC" ><p style="font:'Arial Black', Gadget, sans-serif;font-size:16px">Date of manufacture : <?= $date ?></p></div>
            <div style="margin-left:320px;border-bottom:1px solid #CCC" ><p style="font:'Arial Black', Gadget, sans-serif;font-size:16px">Sumary: <?= $sub ?></p></div>
            <?php
				$queryCom = mysql_query("select * from company where ComID=$company");
				while($rsCom=mysql_fetch_array($queryCom)){
					$comName=$rsCom['Name'];
			?>
            <div style="margin-left:320px;border-bottom:1px solid #CCC" ><p style="font:'Arial Black', Gadget, sans-serif;font-size:16px">Company: <?= $comName ?></p></div>
            <?php
				};
			?>
            </div>
            <div style="margin:70px 0 30px 0"><?= $content ?></div>
            <div style="height:30px;width:100%"><a href="persion.php?id=<?=$id?>">
                        <img style="margin-left:550px;" src="images/order.png" />
                        </a> </div>
             <?php
							};
					}else{
        echo("<script>window.location='cars.php'</script>");
    }
				?>
                
      <!-- comment -->
      
      <div class="title-comment">Comment</div>
        <div class="show-comment">
        <?php
			$id = $_REQUEST["id"];
            $sql="Select * from commentcar where CarID=$id";
            $re=mysql_query($sql);
            while($rs=mysql_fetch_array($re)){
                $name=$rs['Name'];
                $content=$rs['Content'];
                $email=$rs['Email'];
                $title=$rs['Title'];
        ?>
            <div class="item-comment">
                <div class="person-name"><?=$name;?> <span class="person-email">email: <?=$email;?></span></div>
                <div class="person-content"><?=$content;?></div>
            </div>
        <?php }?>
        </div>
    
      <div class="comment-news">
    	<div class="text-comment">Write Comment</div>
        <div class="form-comment">
        	<form name="form" name="FormCommentNews" enctype="multipart/form-data" onsubmit="return ValidateComment(this);" method="post" action="" onreset="this.comment-name.focus();">
                <table>
                    <tr>
                        <td>Name:</td>
                        <td><input type="text" name="comment-name" class="textbox-comment" /></td>
                    </tr>
                    <tr>
                        <td>Email:</td>
                        <td><input type="text" name="comment-email" class="textbox-comment" /></td>
                    </tr>
                    <tr>
                        <td>Title:</td>
                        <td><input type="text" name="comment-title" class="textbox-comment" /></td>
                    </tr>
                    <tr>
                        <td>Content:</td>
                        <td><textarea name="comment-content" class="textbox-comment"  style="width:500px; height:100px;" ></textarea></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <input type="submit" name="btnSave"  class="button-form" value="Save" onclick="return ValidateComment();" />
                            <input type="reset" name="btnReset"  class="button-form" value="Clean" />
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
      <!-- end comment -->
      </div>
      
    <!-- InstanceEndEditable --><!-- InstanceBeginEditable name="rightmenu" -->
    <div class="sidebar">
      <div class="searchform"></div>
      <div class="clr"></div>
      
      <div class="gadget">
        <h2 class="star"><span>Hot</span> Cars</h2>
        <div class="clr" style="height:150px; border:1px solid #960"><img style="height:150px;width:240px" src="images/hotcar1.jpg" style="border: none;"  /></div>
        <div class="clr" style="height:150px;margin-top:10px; border:1px solid #960"><img style="height:150px;width:240px" src="images/hotcar2.jpg" style="border: none;"  /></div>
        <div class="clr" style="height:150px;margin-top:10px; border:1px solid #960"><img style="height:150px;width:240px" src="images/hotcar3.jpg" style="border: none;"  /></div>
        <div class="clr"></div>
      </div>
      <div class="gadget">
        <h2 class="star"><span>Soports</span></h2>
        <div class="clr">
			<script type="text/javascript" src="http://download.skype.com/share/skypebuttons/js/skypeCheck.js"></script>
            <a href="skype:minhthang.one?call"><img src="http://mystatus.skype.com/bigclassic/minhthang.one" style="border: none;"  />		</a>
            <a href="skype:minhthang.one?call"><img src="http://mystatus.skype.com/bigclassic/minhthang.one" style="border: none;"  />		</a>
            <a href="skype:minhthang.one?call"><img src="http://mystatus.skype.com/bigclassic/minhthang.one" style="border: none;"  />		</a>
        </div>
        <ul class="ex_menu">
          <li></li>
        </ul>
      </div>
    </div>
    <!-- InstanceEndEditable -->
    <div class="clr"></div>
    </div>
  </div>
  <div class="fbg">
    <div class="fbg_resize">
    School: Hanoi-Aptech</br>
    Class: A0910G - Group 2</br>
    Project Name: AutoShop
      <div class="clr"></div>
    </div>
  </div>
  <div class="footer">
    <div class="footer_resize">
      <div style="clear:both;"></div>
    </div>
  </div>
</div>
</body>
<!-- InstanceEnd --></html>
